package cn.baiweigang.uu.enums;

public enum StrategyStatusEnum {
    INIT("INIT", "初始状态，开始加载策略配置"),
    WAIT_TO_OPEN("WAIT_TO_OPEN", "加载策略成功，等待开仓挂单"),
    EXIST_OPEN_ORDER("EXIST_OPEN_ORDER", "开仓单已委托成功，等待成交"),
    OPEN_ORDER_DEAL("OPEN_ORDER_DEAL", "开仓委托单已全部成交"),
    WAIT_TO_CLOSE("WAIT_TO_CLOSE", "等待挂 平仓委托单"),
    EXIST_CLOSE_ORDER("EXIST_CLOSE_ORDER", "平仓单已委托成功，等待成交"),
    CLOSE_ORDER_DEAL("CLOSE_ORDER_DEAL", "平仓委托单已全部成交"),
    END("END", "一次自动化交易过程结束"),

    ;
    private String code;
    private String desc;

    StrategyStatusEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static StrategyStatusEnum byCode(String code) {
        StrategyStatusEnum[] periodEnums = values();
        for (int i = 0; i < periodEnums.length; i++) {
            if (code != null && code.equalsIgnoreCase(periodEnums[i].getCode())) {
                return periodEnums[i];
            }
        }
        return null;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }
}
